/**
 * 客户资源转交处理
 */

//页面载入初始化
$( "body" ).ready( function( e )
{
	// 初始化
	state_init();
} );

function state_init()
{
	$( "#statelist :checkbox[value='o3dpi9gzuol4']" ).change( function()
	{
		var a = $( this );
		var b = $( "#statelist :checkbox[value='138g5wfwm1mx']" );
		check_single_selected( a.prop( "checked" ), b.prop( "checked" ), $( this ) );
		set_target_visible( $( "#date_target" ), $( this ).prop( "checked" ) );

	} );

	$( "#statelist :checkbox[value='138g5wfwm1mx']" ).change( function()
	{
		var a = $( this );
		var b = $( "#statelist :checkbox[value='o3dpi9gzuol4']" );
		check_single_selected( a.prop( "checked" ), b.prop( "checked" ), $( this ) );
		set_target_visible( $( "#date_target" ), $( this ).prop( "checked" ) );
	} );
}

//--------------------------------------------------------------------------
//
//	methods
//
//--------------------------------------------------------------------------

/**
 * 转交和计划跟踪不能同时设定
 */
function check_single_selected( a, b, self )
{
	if( a && b )
	{
		infopad.err( "“计划跟踪”和“已转交”不能同时设定。" );
		self.prop( "checked", false );
	}
}

function set_target_visible( tar, value )
{
	if( value )
	{
		tar.show();
	}
	else
	{
		tar.hide();
	}
}
